<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta charset="UTF-8"/>
    <title>报表</title>
    <script src="/jquery-3.3.1/jquery-3.3.1.js"></script>
    <script src="/js/LodopFuncs.js"></script>
</head>

<body style="background-color: rgb(196, 196, 196);">
    <div id="scriptKeyId" hidden>${scriptKey}</div>
    <div id="pageNo" hidden>${pageNo}</div>
    <div id="fileName" hidden>${fileName}</div>
    <div class="table_div">
        <div class="pageUp_btn" id="pageUp">上一页</div>
        <div class="pageDown_btn" id="pageDown">下一页</div>
        <div class="export_btn" id="export">导出</div>
		<div class="print_btn" id="print">打印</div>
        ${table}
    </div>
</body>
</html>

<script>

    //判断是否IE浏览器
    function isIE() {
        if (!!window.ActiveXObject || "ActiveXObject" in window) {
            return true;
        } else {
            return false;
        }
    }

    $(function() {
      $('#export').click(function() {
        $.get("export/" + $('#scriptKeyId').text(), {
        }, function(data, textStatus) {
            var link = document.createElement('a');
            link.href="export/download/" + data;
            link.click();
        });
      });

      $('#print').click(function() {
        $.get("print/" + $('#scriptKeyId').text(), {
        }, function(data, textStatus) {
            var lodop = getLodop();
            if(!lodop){
                alert('请联系管理员，先安装LODOP打印控件!');
                return;
            }
            lodop.SET_LICENSES("北京中电兴发科技有限公司","BC32B3E98EE17DECE56AD090A683CA08","北京中電興發科技有限公司","581DC03916E72807C08528A17E4F906F");
            lodop.SET_PRINT_STYLE("FontSize",6);
            lodop.SET_PRINT_PAGESIZE(1, "300mm", "200mm", "A4");
            data.forEach(function(script) {
                lodop.ADD_PRINT_HTM("5mm","10mm","RightMargin:10mm","BottomMargin:5mm", script);
                lodop.NEWPAGE();
            });
            lodop.PREVIEW(); // 打印预览
            // LODOP.PRINT(); //直接打印
        });
      });

      $('#pageDown').click(function() {
        let scriptKey = $('#scriptKeyId').text();
        let pageNoValue = Number($('#pageNo').text())+1;
        window.location.href='./' + scriptKey +'?pageNo=' + pageNoValue;
      });

      $('#pageUp').click(function() {
        let scriptKey = $('#scriptKeyId').text();
        let pageNoValue = Number($('#pageNo').text())-1;
        if (pageNoValue <= 0) {
            pageNoValue = 0;
        }
        window.location.href='./' + scriptKey +'?pageNo=' + pageNoValue;
      });

    });

</script>

<style>
    .title{
		text-align: center;
		font-weight: bolder;
		font-size: 24px;
		font-family: 宋体;
    }
	.title_bodder{
		margin-top: 5px;
		height: 2px;
		border-top: 1px solid #000000;
		border-bottom: 2px solid #000000;
	}
	.table_div{
		margin: 10px auto;
		padding: 80px 25px;
		background-color: #FFFFFF;
		position: fixed;
		left: 10%;
		right: 10%;
		bottom: 10px;
		top: 10px;
		height: auto;
		overflow-y: auto;
	}
    .table_div::-webkit-scrollbar {
	  /*滚动条整体样式*/
	  width : 2px;  /*高宽分别对应横竖滚动条的尺寸*/
	  height: 1px;
    }

	.table_div::-webkit-scrollbar-thumb {
	  /*滚动条里面小方块*/
	  border-radius: 10px;
	  box-shadow   : inset 0 0 5px rgba(0, 0, 0, 0.2);
	  background   : rgb(196,196,196);
    }

    .table_div::-webkit-scrollbar-track {
      /*滚动条里面轨道*/
      box-shadow   : inset 0 0 5px rgba(0, 0, 0, 0.2);
      border-radius: 10px;
      background   : rgb(196,196,196);
    }

	.print_btn{
		position: absolute;
		top: 20px;
		margin-left: 10px;
		right: 30px;
		width: 80px;
		height: 30px;
		z-index: 999;
		background-color: #3f51b5;
		color: #FFF;
		text-align: center;
		line-height: 1.9;
		border-radius: 7px;
		cursor:pointer;
	}

	.export_btn{
		position: absolute;
		top: 20px;
		margin-left: 10px;
		right: 120px;
		width: 80px;
		height: 30px;
		background-color: #F44336;
		color: #FFF;
		z-index: 999;
		text-align: center;
		line-height: 1.9;
		border-radius: 7px;
		cursor:pointer;
	}

    .pageUp_btn{
		position: absolute;
		top: 20px;
		margin-left: 10px;
		left: 30px;
		width: 80px;
		height: 30px;
		background-color: #3f51b5;
		color: #FFF;
		z-index: 999;
		text-align: center;
		line-height: 1.9;
		border-radius: 7px;
		cursor:pointer;
	}
    .pageDown_btn{
		position: absolute;
		top: 20px;
		margin-left: 10px;
		left: 120px;
		width: 80px;
		height: 30px;
		background-color: #F44336;
		color: #FFF;
		z-index: 999;
		text-align: center;
		line-height: 1.9;
		border-radius: 7px;
		cursor:pointer;
	}
    .lineTd {
        background: #fff url() no-repeat 100% center;
    }
</style>